﻿using System;
using System.Net;
using System.Net.Sockets;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;

namespace Mobile
{
    class Program
    {
        static void Main(string[] args)
        {
            MobileServer();
        }


        private static void MobileServer()
        {
            int port = 1820;
            IPEndPoint remoteServer = new IPEndPoint(IPAddress.Parse("10.9.146.31"), 1819);

            IPEndPoint localEP = new IPEndPoint(IPAddress.Any, port);
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            try
            {
                socket.Bind(localEP);
                Console.WriteLine("手机模拟器启动了....");

                Console.WriteLine("请打开 http://localhost:8075/test.html");

                Console.WriteLine("请输入您看到的GUID码");

                string guid = Console.ReadLine();
                byte[] data = Encoding.UTF8.GetBytes(guid);

                socket.SendTo(data, data.Length, SocketFlags.None, remoteServer);
                Console.WriteLine("已经把GUID发送至手机通讯服务器");
                Console.ReadLine();

            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
    }
}